package com.mobjam.workingtitleforagame.UnitTests;

import com.mobjam.workingtitleforagame.Map;
import com.mobjam.workingtitleforagame.MapObject;
import com.mobjam.workingtitleforagame.MapRegion;
import com.mobjam.workingtitleforagame.MapTile;

import android.test.AndroidTestCase;

public class MapTest extends AndroidTestCase{
	Map myMap;
	MapRegion [][] regions;
	public void setUp() throws Exception {
		super.setUp();
		MapObject.loadBitmaps(getContext());
		MapTile.loadBitmaps(getContext());
		myMap = new Map(getContext(), 2, 2, 5, 5, 8, 8, 0, 0, 0, 0);
		regions = myMap.getMapRegions();
	}

	public void tearDown() throws Exception {
		super.tearDown();
	}
	
	public void testMap()
	{
		for( int i = 0; i < 2; i++ )
		{
			for( int j = 0; j < 2; j++ )
			{
				if( i > 0 )
				{
					assertTrue( regions[i][j].getWestRegion().equals(regions[i-1][j] ) );
				}
				
				if( i < 1 )
				{
					assertTrue(regions[i][j].getEastRegion().equals(regions[i+1][j]));
				}
				
				if( j > 0 )
				{
					assertTrue( regions[i][j].getNorthRegion().equals(regions[i][j-1]));
				}
				
				if( j < 1 )
				{
					assertTrue(regions[i][j].getSouthRegion().equals(regions[i][j+1]));
				}
			}
		}
	}
	
	public void testCurrentRegion()
	{
		assertTrue( regions[0][0].equals( myMap.getCurrentRegion()));
	}
	
	public void testCharacterLocation()
	{
		assertTrue(com.mobjam.workingtitleforagame.Character.getInstance().getCurrentTile().equals(myMap.getCurrentRegion().getMapTiles()[0][0]));
	}
	
	public void testMoveCharacter()
	{
		assertTrue(myMap.moveCharacterEast() );
		assertTrue(myMap.moveCharacterSouth());
		assertTrue(myMap.moveCharacterSouth());
		assertTrue(myMap.moveCharacterSouth());
		assertTrue(com.mobjam.workingtitleforagame.Character.getInstance().getCurrentTile().equals(myMap.getCurrentRegion().getMapTiles()[1][3]));
	}
}
